package com.shen.company;

import java.util.HashMap;
import java.util.Map;

/**
 * Author:shen
 * CreateDate:2020/5/11.
 * Function:
 */
public class Company {
    private String name;
    private String address;
    private String phone;
    private String info;
    private static Map<Integer,Employee> employeeMap=new HashMap<>();

    private static int employeeId=3;
    /**
     * 初始化员工
     */
    static {
        employeeMap.put(1,new Employee("张三",1,'男',"项目经理",30000));
        employeeMap.put(2,new Employee("李四",1,'男',"组员A",8000));
        employeeMap.put(3,new Employee("王五",1,'男',"组员B",8000));
    }

    /**
     * 添加员工
     */
    public void addEmployee(Employee employee){
        employeeMap.put(employeeId+1,employee);
    }

    /**
     * 删除员工
     */
    public void deleteEmployee(int index){
        employeeMap.remove(index);
    }

    /**
     * 统计公司人数
     */
    public void countPerson(){
        System.out.println(employeeMap.size());
    }

    /**
     * 薪水最高的员工的方法
     */
    public Employee getTopSalary(){
        double isflag=0;
        Employee employee=null;
        for (Map.Entry<Integer,Employee> entry:employeeMap.entrySet()) {
            if(isflag<entry.getValue().getSalary()){
                isflag=entry.getValue().getSalary();
                employee=entry.getValue();
            }
        }
        return employee;
    }

    public Company() {
    }

    public Company(String name, String address, String phone, String info) {
        this.name = name;
        this.address = address;
        this.phone = phone;
        this.info = info;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }


    @Override
    public String toString() {
        return "Company{" +
                "name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", phone='" + phone + '\'' +
                ", info='" + info + '\'' +
                ", employee=" + employeeMap.toString() +
                '}';
    }
}
